import {Component, OnInit} from '@angular/core';
import {_HttpClient} from '@delon/theme';
import {TeacherService} from '../teacher.service';
import {NzMessageService} from 'ng-zorro-antd';

@Component({
    selector: 'app-list',
    templateUrl: './list.component.html',
})
export class ListComponent implements OnInit {

    total = 0;
    pagesize = 10;
    pageCureent = 1;
    data: any[] = [];


    constructor(
        private teacherServer: TeacherService,
        private msg: NzMessageService,
    ) {
    }

    ngOnInit() {
        this.getlist(this.pageCureent);
    }

    getlist($event) {
        this.teacherServer.getlist($event - 1).subscribe(res => {
            this.data = res['list'];
            this.total = res['totalElement'];
            this.pagesize = res['pageSize'];
            this.pageCureent = $event;
        });
    }

    delTeacher(teacher) {
        this.teacherServer.delteacher(teacher.id).subscribe(res => {
            this.msg.success('删除成功');
            this.getlist(this.pageCureent);
        });
    }

}
